﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects.DataClasses;

namespace FRL.DebtChased.Repository
{

	/// <summary>
	/// Extensions to the InterestRateHistory model
	/// </summary>
	public partial class InterestRateHistory
	{

		/////////////////////////////////////////////////////////////
		// Static Operations

		public static double GetCurrentRate(DebtChasedEntities ent)
		{

			// Look up the latest rate
			double dblFtmp = (from irh in ent.InterestRateHistories
							  orderby irh.AppliedAt descending
							  select irh.Perc).FirstOrDefault();

			// Return variable
			return dblFtmp;

		}

	}

}
